package com.campus.marketplace.repository;

import com.campus.marketplace.entity.Report;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;

public interface ReportRepository extends JpaRepository<Report, Long> {
    List<Report> findByReporterIdOrderByCreatedAtDesc(Long reporterId);

    List<Report> findByTargetTypeAndTargetIdOrderByCreatedAtDesc(String targetType, Long targetId);

    List<Report> findByStatusOrderByCreatedAtDesc(String status);

    @Query("SELECT COUNT(r) FROM Report r WHERE r.targetType = :targetType AND r.targetId = :targetId")
    Long countByTarget(@Param("targetType") String targetType, @Param("targetId") Long targetId);

    @Query("SELECT r FROM Report r WHERE r.status = :status AND r.reportType = :reportType")
    List<Report> findByStatusAndReportType(@Param("status") String status, @Param("reportType") String reportType);
}